package hotciv.variants;

import hotciv.common.CityImpl;
import hotciv.common.UnitImpl;
import hotciv.common.WorldMap;
import hotciv.framework.ActionStrategy;
import hotciv.framework.GameConstants;
import hotciv.framework.Position;
import hotciv.framework.Unit;

public class GammaAction implements ActionStrategy {

	@Override
	public void performAction(Position p, WorldMap w) {
		  Unit unit = w.getUnitAt(p);
		  if (unit.getTypeString().equals(GameConstants.SETTLER) && w.getCityAt(p) == null) {
			  w.removeUnitAt(p);
			  w.setCityAt(p, new CityImpl(unit.getOwner(), GameConstants.ARCHER, GameConstants.productionFocus));  
		  } else if (unit.getTypeString().equals(GameConstants.ARCHER)) {
			  if (unit.getMoveCount()==0) w.setUnitAt(p, new UnitImpl(GameConstants.ARCHER, unit.getOwner()));
			  else w.setUnitAt(p, new UnitImpl(GameConstants.FORTIFIED_ARCHER, unit.getOwner()));
		  }
	}

}
